package net.akkz.action.student;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.akkz.beanFactory.BeanFactory;
import net.akkz.model.Student;
import net.akkz.server.StudentServer;

public class StudentActive extends HttpServlet
{
	private StudentServer studentServer;
	
	@Override
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException
	{
		String name = request.getParameter("name");
		int id = Integer.parseInt(request.getParameter("id"));
		
		Student student = new Student();
		student.setName(name);
		student.setId(id);
		
		request.getSession().setAttribute("student", studentServer.active(student));
	}
	
	@Override
	public void init()
	{
		BeanFactory  bf = (BeanFactory) this.getServletContext().getAttribute("beanFactory");
		
		studentServer = bf.getBean("studentServer");
	}
}
